extension/fast-float: gain some speed by ignoring a couple high mantissa bits
authorØyvind Kolås <pippin@gimp.org>
Sat, 19 Nov 2016 12:29:36 +0000 (13:29 +0100)
committerØyvind Kolås <pippin@gimp.org>
Sat, 19 Nov 2016 12:29:36 +0000 (13:29 +0100)
extensions/fast-float.c

index 392bcb5b31e92bc378023583ae1a54893ee89a28..bafdcc0eb5e512f60acfb32cd09f4b6be4385f37 100644 (file)
@@ -28,7 +28,7 @@
 
 #define INLINE inline
 
-#define  LSHIFT 2
+#define  LSHIFT 4
 
 typedef  float (* BablLookupFunction) (float  value,
                                        void  *data);
@@ -92,7 +92,7 @@ babl_lookup (BablLookup *lookup,
   }
 
   {
-    uint32_t bm =u.i & 0b11000000000000000000000000000000;
+    uint32_t bm =u.i & 0b11110000000000000000000000000000;
     ua.i |= bm;
     ub.i |= bm;
   }
@@ -158,6 +158,8 @@ babl_lookup_new (BablLookupFunction function,
   else if (precision <= 0.000649) shift = 15;
   else shift = 16; /* a bit better than 8bit sRGB quality */
 
+  shift = 16;
+
   /* Adjust slightly away from 0.0, saving many entries close to 0, this
    * causes lookups very close to zero to be passed directly to the
    * function instead.
@@ -264,7 +266,6 @@ linear_to_gamma_2_2_lut (float val)
   return babl_lookup (fast_pow, val);
 }
 
-
 static BablLookup *fast_rpow = NULL;
 
 static inline float core_rlookup (float val, void *userdata)
@@ -600,8 +601,8 @@ init (void)
     float a;
 
     /* tweaking the precision - does impact speed.. */
-    fast_pow = babl_lookup_new (core_lookup, NULL, 0.0, 1.0,   0.00033);
-    fast_rpow = babl_lookup_new (core_rlookup, NULL, 0.0, 1.0, 0.00033);
+    fast_pow = babl_lookup_new (core_lookup, NULL, 0.0, 1.0,   0.0033);
+    fast_rpow = babl_lookup_new (core_rlookup, NULL, 0.0, 1.0, 0.0033);
 
     for (f = 0.0; f < 1.0; f+= 0.0000001)
       {